//侧边栏导航
let navBox = document.querySelectorAll('.top-content>p')

let navBtn = document.querySelectorAll('.floor p')
let index = 0;
navBtn.forEach(function (v, i) {
    // console.log(v);
    v.addEventListener('click', function () {
        navBtn[index].classList.remove('active')
        this.classList.add('active')
        index = i;
        window.scrollTo({
            top: navBox[i].offsetTop + 360,
            behavior: "smooth"
        })


    })
    // console.log(navBox[i].offsetTop);
})
let elevatorPosition = document.querySelector('.floor')
//滑到一定距离绝对定位变固定定位
window.addEventListener('scroll', function () {
    if (document.documentElement.scrollTop >= 400) {
        elevatorPosition.style.position = 'fixed'
    } else {
        elevatorPosition.style.position = 'absolute'
    }
})